package src.array;

public class no1207 {
    //独一无二的出现次数
    public static void main(String[] args) {
        int[] arr={-3,0,1,-3,1,1,1,-3,10,0};
        System.out.println(uniqueOccurrences(arr));

    }

    public static boolean uniqueOccurrences(int[] arr) {
        int[] hashArray = new int[2001];  //因为有负数，所以要让负数也映射进哈希数组
        for (int i = 0; i < arr.length; i++) {
            hashArray[arr[i] + 1000]++;
        }
        boolean[] count = new boolean[arr.length + 1];
        for (int i = 0; i < hashArray.length; i++) {
            if (hashArray[i] > 0) {

                //bool数组默认false，再hash映射一次，如果次数相同了，则发现这个格子为true，直接return false
                if (count[hashArray[i]] == false) {
                    count[hashArray[i]] = true;
                } else {
                    return false;
                }
            }

        }
        return true;

    }
}
